#ExtDNVoice- voice, ExtDNAM - am, ExtDNFax - fax, ExtDNNoAnswer - no answer, ExtDNBusy - busy
import random
def cpd_transfer_load():
  numbers = [ExtDNVoice, ExtDNAM,  ExtDNNoAnswer, ExtDNBusy]
  maxCycle = 10
  maxMakeCall = 10
  timeoutConnect = 10
  i = 0
  CPD1.CPDReleaseAllAgents(ACD1, waitEvents = 0)
  CPD1.cpdServer.WaitAllEvents()
  try:
    for i in range (0, maxCycle ):
      for j in range (0, maxMakeCall):
        dest = random.choice(numbers)
        CPD1.CPDMakePredictiveCall(dest, waitEvents = 0)

      CPD1.cpdServer.WaitAllEvents(timeout = 2)
      LocalTserver.WaitAllEvents(timeout = 2)
      time.sleep(timeoutConnect) 

      for ag in LocalTserver.AgentList:
        LocalTserver.ReleaseCall(ag.dn.number)
      LocalTserver.WaitAllEvents()

  except KeyboardInterrupt:
    print "STOP"
    CPD1.cpdServer.WaitAllEvents(timeout = 2)
    LocalTserver.WaitAllEvents(timeout = 2)

  CPD1.cpdServer.WaitAllEvents()
  LocalTserver.WaitAllEvents()